package com.co.notaweb.bussines.system;

import java.util.List;

import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import com.co.notaweb.entities.system.Rol;

/**
 * @author PC
 * @version 1.0
 * @created 13-nov-2011 12:14:23
 */
@Stateless
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public class RolBussines implements IRolBussinesLocal {
	@PersistenceContext(unitName = "notaweb")
	private EntityManager em;

	public RolBussines() {

	}

	/**
	 * 
	 * @param rol
	 */
	public void create(Rol rol) {
		em.persist(rol);

	}

	/**
	 * 
	 * @param rol
	 */
	public void delete(Rol rol) {
		
	}

	/**
	 * 
	 * @param rol
	 */
	public void edit(Rol rol) {
		em.merge(rol);
	}

	/**
	 * 
	 * @param id
	 */
	public Rol find(long id){
		return em.find(Rol.class, id);
	}
	
	
	public List <Rol> consultarAllRoles(){
		List<Rol> list = em.createNamedQuery("Rol.consultarAllRoles").getResultList();
		if(!list.isEmpty()){
			return list; 
		}
		return null;
	}
		

}